<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>前端三剑客🎉渐变 | 小李博客</title><meta name="keywords" content="HTML+CSS"><meta name="author" content="小李博客"><meta name="copyright" content="小李博客"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="什么是渐变 CSS 渐变是 CSS3 的 Image 模块中新增的内容。利用 CSS 渐变替代在 HTML 页面中引入渐变效果的图片，这样减少 HTML 页面加载的时间，减小带宽的占用。 由于 CSS 渐变是由浏览器直接生成，在 HTML 页面缩放时的效果要比图片更好，使得可以更灵活、便捷地调整 HTML 页面布局。  线性渐变 线性渐变由一个轴 (基准线) 定义的，并且轴上每个点都具有独立的颜色">
<meta property="og:type" content="article">
<meta property="og:title" content="前端三剑客🎉渐变">
<meta property="og:url" content="http://xiaoliblog.cn/page/css13.html">
<meta property="og:site_name" content="小李博客">
<meta property="og:description" content="什么是渐变 CSS 渐变是 CSS3 的 Image 模块中新增的内容。利用 CSS 渐变替代在 HTML 页面中引入渐变效果的图片，这样减少 HTML 页面加载的时间，减小带宽的占用。 由于 CSS 渐变是由浏览器直接生成，在 HTML 页面缩放时的效果要比图片更好，使得可以更灵活、便捷地调整 HTML 页面布局。  线性渐变 线性渐变由一个轴 (基准线) 定义的，并且轴上每个点都具有独立的颜色">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png">
<meta property="article:published_time" content="2021-01-19T04:21:06.668Z">
<meta property="article:modified_time" content="2021-04-29T12:18:25.874Z">
<meta property="article:author" content="小李博客">
<meta property="article:tag" content="HTML+CSS">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png"><link rel="canonical" href="http://xiaoliblog.cn/page/css13"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.js" defer></script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: {"appId":"RTG4CPNBLJ","apiKey":"f1745bdad68ceec57653b78244fe332c","indexName":"MyBlogIndex","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":100,"languages":{"author":"作者: 小李博客","link":"链接: ","source":"来源: 小李博客","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'mediumZoom',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-center"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-04-29 20:18:25'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><link rel="stylesheet" href="/css/MyStyle/MyStyle.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="/css/MyStyle/tagStyle.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zykjofficial/zykjresource@master/css/font-awesome-animation.min.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/plugins.min.css" media="defer" onload="this.media='all'"><meta name="generator" content="Hexo 5.2.0"><link rel="alternate" href="/atom.xml" title="小李博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">210</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">38</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">56</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/box/"><i class="fa-fw fa fa-briefcase"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-book"></i><span> 找文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-address-card"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">小李博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/box/"><i class="fa-fw fa fa-briefcase"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-book"></i><span> 找文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-address-card"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">前端三剑客🎉渐变</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-01-19T04:21:06.668Z" title="发表于 2021-01-19 12:21:06">2021-01-19</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-04-29T12:18:25.874Z" title="更新于 2021-04-29 20:18:25">2021-04-29</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Web%E5%89%8D%E7%AB%AF/">Web前端</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Web%E5%89%8D%E7%AB%AF/HTML-CSS/">HTML+CSS</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">4.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>18分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="前端三剑客🎉渐变"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div><article class="post-content" id="article-container"><h1 id="什么是渐变"><a href="#什么是渐变" class="headerlink" title="什么是渐变"></a>什么是渐变</h1><ul>
<li>CSS 渐变是 CSS3 的 Image 模块中新增的内容。<strong>利用 CSS 渐变替代在 HTML 页面中引入渐变效果的图片</strong>，这样减少 HTML 页面加载的时间，减小带宽的占用。</li>
<li>由于 CSS 渐变是由浏览器直接生成，在 HTML 页面缩放时的效果要比图片更好，使得可以更灵活、便捷地调整 HTML 页面布局。</li>
</ul>
<h1 id="线性渐变"><a href="#线性渐变" class="headerlink" title="线性渐变"></a>线性渐变</h1><ul>
<li><p>线性渐变由一个轴 (基准线) 定义的，并且轴上每个点都具有独立的颜色。<code>lincar-gradient() </code>函数构建垂直于基准线的渐变效果，渐变的颜色取决于与之垂直相交的基准线上的色点。</p>
</li>
<li><p>基准线由包含渐变效果容器元素的中心点和一个角度来定义的。基准线上的颜色值则由不同的点来定义，包括起始点、终止点以及两者之间可选的中间点 (中间点可以有多个)</p>
</li>
<li><p>起始点是基准线和容器元素的顶点与基准线垂直线的相交点来定义。</p>
</li>
<li><p>终止点是基准线和容器元素最近顶点与基准线垂直线的相交点来定义。</p>
</li>
<li><p>渐变的 0 度是从下到上的，增加角度会使渐变顺时针旋转。</p>
</li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@d04bc202913a9f026ff1170ca11acba6bacb71f7/2021/01/19/4f53cccb477dfccce3a39b78e9bfd4fd.png"></p>
<p>CSS linear gradient () 函数用于创建一个表示两种或多种颜色线性渐变的图片。具体语法结构如下:<br><code>linear-gradient(angle/direction, color-stop1, color-stop2, ...)</code><br>上述语法的参数说明:</p>
<ul>
<li>第一个参数用于定义线性渐变的方向，并且定义渐变颜色的终止位置。 默认第一个参数如果不写就是从上到下的<ul>
<li><code>angle</code>: 通过角度来定义渐变的方向。0 度表示渐变方向从下向上，90 度表示渐变从左向右。其角度按照顺时针方向增加。</li>
<li><code>direction</code>: 通过关键字定义渐变的方向。表示水平位置 (left 或 right)，表示垂直位置 (top 或 bottom) 。关键字的先后顺序无影响，并且都是可选的。</li>
</ul>
</li>
<li>第二个参数、第三个参数用于定义渐变颜色的起始点和终止点。</li>
</ul>
<h2 id="方向参数direction"><a href="#方向参数direction" class="headerlink" title="方向参数direction"></a>方向参数direction</h2><ul>
<li><strong>默认第一个参数如果不写就是从上到下的</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@d6407b7d1bd5565f9e5cc0ea7877ad7b3be1edcc/2021/02/03/28926bc6ed91181b9fc9d3de9af454a7.png"></p>
<ul>
<li><strong>第一个参数为方位名词</strong><ul>
<li>原生写法加to，所以后面的方向正好相反，而且对角线的时候上下和左右可以互换位置=</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.box1</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to bottom,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box2</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to right,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box3</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to left,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box4</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to top,hotpink, darkblue); </span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box5</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to right bottom,hotpink, darkblue); </span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box6</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to top right,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box7</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to left bottom,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box8</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to top left,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@68adfa819a2fd28c83df195a1f2773a32d6c31e7/2021/02/03/b851acff68df5c093e10551459fcf819.png"></p>
<ul>
<li><strong>使用角度angle（角度值deg）进行控制</strong><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@1fa71942d65d9abe641d8ed8593e4fc6db157f3e/2021/02/03/6eb2a21356596b3d7eb3e744027b6137.png" width="50%"><ul>
<li>所有的颜色都是从中心出发，0deg是to top的方向，顺时针是正，逆时针是负</li>
<li>0deg / 360deg （从下到上）</li>
<li>90deg （从左到右）</li>
<li>180deg （从上到下）</li>
<li>270deg / -90deg （从右到左）</li>
<li>45deg （对角线左下到右上）</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">0deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">90deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">180deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">270deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">360deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(-<span class="number">90deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(-<span class="number">180deg</span>,#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">45deg</span>,#fc466b, #<span class="number">3</span>f5efb)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@136d4235a9fcc885c7cc28646866660ce19923a7/2021/02/03/e1059bc027c21a22e9f4d24197ab303e.png"></p>
<h2 id="颜色参数"><a href="#颜色参数" class="headerlink" title="颜色参数"></a>颜色参数</h2><ul>
<li><strong>颜色英文字母表示</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(slateblue, cornflowerblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@243d32094ad0246ae21272901ab80991227dd0ca/2021/02/03/366b065eab0ea8537fec97d5d7f01315.png"></p>
<ul>
<li><strong>使用<code>transparent</code>全透明渐变色</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(transparent, cornflowerblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@4445d8c0401c2150827821c1cc63525b30506b2d/2021/02/03/195c65cd88d3c3c44e4717e9de7a71b5.png"></p>
<ul>
<li><strong>十六进制#RRGGBB进行颜色控制</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(#fc466b, #<span class="number">3</span>f5efb);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@f8512c913c1bad1973b268565876cef52cf7f59a/2021/02/03/33738a50e28facce2bcd50dd00f663a7.png"></p>
<ul>
<li><strong>使用<code>rgb/rgba</code>进行颜色控制</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(rgb(<span class="number">255</span>,<span class="number">237</span>,<span class="number">188</span>), <span class="built_in">rgb</span>(<span class="number">237</span>,<span class="number">66</span>,<span class="number">100</span>));   <span class="comment">/*rbg*/</span></span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(rgb(<span class="number">255</span>,<span class="number">237</span>,<span class="number">188</span>,.<span class="number">5</span>), <span class="built_in">rgb</span>(<span class="number">237</span>,<span class="number">66</span>,<span class="number">100</span>,.<span class="number">5</span>));  <span class="comment">/*rgba*/</span></span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@ec693479d76cbcf02ae50419f9696b6c2f95d1fb/2021/02/03/8d9bd0002f4314dea237ac8fc515de85.png"></p>
<ul>
<li><strong>使用多个有指定范围的颜色控制</strong><br>  在颜色后面加百分比，就可以控制在整个宽度的百分之多少的时候到达某一个颜色值</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(#<span class="number">3</span>a1c71, #d76d77,#ffaf7b); </span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(#<span class="number">3</span>a1c71, #d76d77 <span class="number">20%</span> ,#ffaf7b <span class="number">70%</span>); </span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(#<span class="number">3</span>a1c71, #d76d77 <span class="number">80%</span> ,#ffaf7b <span class="number">90%</span>); </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@a8394e1978b94d59a9ae193884faabda723b5e66/2021/02/03/e6e57dc3104a0941d7e14248e9b03fe6.png"></p>
<ul>
<li><strong>线性渐变总写法</strong></li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to bottom,#<span class="number">3</span>a1c71, #d76d77 <span class="number">80%</span> ,#ffaf7b <span class="number">90%</span>); </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="头像滤镜效果"><a href="#头像滤镜效果" class="headerlink" title="头像滤镜效果"></a>头像滤镜效果</h2><p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@c51ac0a18e06f4d6d90af5f90090299eab0211f8/2021/01/19/e43fc800f1fe005a7175da692daa5dee.png"></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        *&#123;</span><br><span class="line">            box-sizing: border-box;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.box1</span>&#123;</span></span><br><span class="line">            width: 200px;</span><br><span class="line">            height: 200px;</span><br><span class="line">            border-radius: 50%;</span><br><span class="line">        &#125;</span><br><span class="line">        img&#123;</span><br><span class="line">            width: 200px;</span><br><span class="line">            float: left;</span><br><span class="line">            border-radius: 50%;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.lvjing</span>&#123;</span></span><br><span class="line">            position: relative;</span><br><span class="line">            width: 100%;</span><br><span class="line">            height: 100%;</span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-tag">linear-gradient</span>(<span class="selector-tag">to</span> <span class="selector-tag">right</span>,<span class="selector-tag">rgba</span>(255,154,158,<span class="selector-class">.7</span>),<span class="selector-tag">rgba</span>(250,208,196,<span class="selector-class">.7</span>));</span></span><br><span class="line">            border-radius: 50%;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;box1&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;https://cdn.jsdelivr.net/gh/blogimg/HexoStaticFile1/imgbed/2020/02/24/20200224111924.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;lvjing&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="进度条动画"><a href="#进度条动画" class="headerlink" title="进度条动画"></a>进度条动画</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;X-UA-Compatible&quot;</span> <span class="attr">content</span>=<span class="string">&quot;ie=edge&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span> <span class="attr">href</span>=<span class="string">&quot;bootstrap-3.3.7-dist/css/bootstrap.min.css&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line">        body &#123;</span><br><span class="line">            margin: 0;</span><br><span class="line">            padding: 0;</span><br><span class="line"><span class="css">            <span class="comment">/*为了展示方便就用灰色的背景*/</span></span></span><br><span class="line"><span class="css">            <span class="selector-tag">background-color</span>: <span class="selector-id">#ccc</span>;</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="css">        <span class="selector-class">.load</span> &#123;</span></span><br><span class="line">            width: 500px;</span><br><span class="line">            height: 100px;</span><br><span class="line"><span class="css">            <span class="comment">/*如果渐变出不来，有一个背景颜色*/</span></span></span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-id">#fff</span>;</span></span><br><span class="line">            margin: 100px auto;</span><br><span class="line"><span class="css">            <span class="comment">/*间隔色的关键代码*/</span></span></span><br><span class="line">            background-image: linear-gradient(45deg,</span><br><span class="line"><span class="css">                    <span class="selector-id">#fff</span> 0%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#fff</span> 25%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#000</span> 25%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#000</span> 50%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#fff</span> 50%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#fff</span> 75%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#000</span> 75%,</span></span><br><span class="line"><span class="css">                    <span class="selector-id">#000</span> 100%);</span></span><br><span class="line"><span class="css">            <span class="comment">/*把刚才的背景压缩到100px * 100px以内的，没有设定不重复所以是重复的*/</span></span></span><br><span class="line">            background-size: 100px 100px;</span><br><span class="line"><span class="css">            <span class="comment">/*一秒播一次的永动动画*/</span></span></span><br><span class="line">            animation: move 1s linear infinite;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="css">        <span class="keyword">@keyframes</span> move &#123;</span></span><br><span class="line"><span class="css">            0% &#123;&#125;</span></span><br><span class="line"></span><br><span class="line">            100% &#123;</span><br><span class="line">                background-position: 100px;</span><br><span class="line"><span class="css">                <span class="comment">/*终止状态是移动到100px像素的位置，然后下一秒又开始从0px开始运动*/</span></span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;load&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@bcc2e706b3cd56f7d9eb3c45b5404a12216fe5a2/2021/02/03/3e23e82387110139fd2529b5e0d80c47.png"></p>
<h1 id="径向渐变"><a href="#径向渐变" class="headerlink" title="径向渐变"></a>径向渐变</h1><p>径向渐变由其中心点、边缘形状轮廓、位置以及颜色结束点定义的。</p>
<ul>
<li> 径向渐变的中心点至边缘形状以及其延伸的部分是由连续缩放的若干同心轮廓组成的。</li>
<li>颜色结束点用于设定虚拟渐变射线的变化方式，由中心点水平变化至右侧。颜色结束点由百分比设定，中心点为 0%，終止点为 100%。终止点为渐变射线与边缘形状相交点的渐变半径。</li>
<li>边缘形状只能是圆形或者椭圆形。</li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@3b184b8eb5669b34ec42cc3f5ef3149368e538c8/2021/01/19/9651aacb6ee196d660f1f7e1def217b7.png"></p>
<p>语法<code> radial-gradient( shape size at position,clor-stop,color-stop+)</code></p>
<ul>
<li><code>shape</code>: 表示设置的渐变形状，默认表示椭圆(ellipse)，circle圆形</li>
<li><code>position</code>: 表示设置起点的坐标值<ul>
<li>第一个值：表示水平方向的值</li>
<li>第二个值：表示垂直方向的值</li>
</ul>
</li>
<li><code>size</code>: 表示设置渐变形状的大小<ul>
<li><code>farthest-corner</code> (默认) : 指定径向渐变的半径长度为从圆心到离圆心最远的角</li>
<li><code>closest-side</code> ：渐变的边缘形状与容器距离渐变中心点最近的一边相切（圆形）或者至少与距离渐变中心点最近的垂直和水平边相切（椭圆）</li>
<li><code>closest-corner</code> ： 指定径向渐变的半径长度为从圆心到离圆心最近的角</li>
<li><code>farthest-side</code> ：与closest-side相反，边缘形状与容器距离渐变中心点最远的一边相切（或最远的垂直和水平边）</li>
<li>圆形<ul>
<li>该值为原型的半径</li>
</ul>
</li>
<li>椭圆形<ul>
<li>值为段半径和长半径</li>
</ul>
</li>
</ul>
</li>
<li><code>color-stop</code>: 表示渐变的颜色，可以多个<ul>
<li>其后也可跟位置 例如<code> #212121 50% 50%</code></li>
</ul>
</li>
</ul>
<h2 id="参数shape"><a href="#参数shape" class="headerlink" title="参数shape"></a>参数shape</h2><ul>
<li>如果只有参数shape（circle,ellipse）<ul>
<li>如果div是正方形那么circle和ellipse并没有什么区别，但是如果是长方形，那么ellipse就会根据长度进行压缩</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle,hotpink, darkblue); <span class="comment">/*下图1和3*/</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(ellipse,hotpink, darkblue); <span class="comment">/*下图2和4*/</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@9ea100909380129f5494f7809b408b9440486977/2021/02/03/cecd2dd303758d089496f33709a00e17.png"></p>
<ul>
<li>如果是加上长度范围和形状<ul>
<li>该范例要说明半径要写到形状前面，且半径作用大于形状</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">300px</span> circle,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">200px</span> circle,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">100px</span> circle,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">50px</span> circle,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">0px</span> circle,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*如果这里加了长短轴的尺寸后面又写了circle，那么circle是不起作用的，出来还是一个椭圆*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">200px</span> <span class="number">50px</span> ellipse,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@d261b250114f979e18fa39ec412905c05fedc84f/2021/02/03/215e5dd631512785b13992dad7e9a137.png"></p>
<h2 id="参数size"><a href="#参数size" class="headerlink" title="参数size"></a>参数size</h2><ul>
<li>第一个参数不写就默认从中间开始，样式为圆形</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@97d39977d7cc813fa19f0a8760bd68420a214c83/2021/02/03/5432099ca8cfe61774b36f62f99e4a32.png"></p>
<ul>
<li>传一个半径值</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">300px</span>,hotpink, darkblue);</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">200px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@9d11ed6ab75066ad6c2eba70e050b4aa0d46e4b3/2021/02/03/5ae05a7389f55e859cffd85be38490d0.png"></p>
<ul>
<li>传两个半径值<br>  传两个值默认为椭圆，一个是横向的长度，一个是纵向的长度</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">200px</span> <span class="number">50px</span>,hotpink, darkblue);</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">50px</span> <span class="number">100px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@8bb127281df2c8ebab5d3320b2cb786f471fdf8c/2021/02/03/045dd74ba3c9af3ba03e669d57838f77.png"></p>
<ul>
<li><p>如果传关键字(<code>closest-side/closest-corner/farthest-side/farthest-corner</code>)</p>
<ul>
<li>这个大小是由位置决定的</li>
</ul>
</li>
<li><p>如果是圆形</p>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*closest-side*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*40%只写一个表示40% 50%*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123; </span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side circle at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);  </span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side circle at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*closest-corner*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner,#ffaf7b, #d76d77  ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner circle at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner circle at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*farthest-side*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side circle at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side circle at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*farthest-corner*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner circle at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner circle at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@9ee49635d952e405797f57d257dd5d7d64e27a02/2021/02/03/891eb3fb5cc30842f3ad7618cc86f6dc.png"></p>
<ul>
<li>如果是椭圆</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*closest-side*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side ellipse,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*40%只写一个表示40% 50%*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123; </span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side ellipse at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);  </span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-side ellipse at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*closest-corner*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner ellipse,#ffaf7b, #d76d77  ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner ellipse at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(closest-corner ellipse at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*farthest-side*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side ellipse,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side ellipse at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-side ellipse at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*farthest-corner*/</span></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner ellipse,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner ellipse at <span class="number">40%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(farthest-corner ellipse at <span class="number">20%</span> <span class="number">30%</span>,#ffaf7b, #d76d77 ,#<span class="number">3</span>a1c71);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@847b23410d5f07044139f51d44d96306f6fabaa8/2021/02/03/b08efae1d864c6be3de4c895860e69b7.png"></p>
<h2 id="参数position"><a href="#参数position" class="headerlink" title="参数position"></a>参数position</h2><ul>
<li><strong>如果第一个有参数(center/top/bottom/left/right)</strong><ul>
<li>如果是原生写法记得要加at，而且对角线的时候上下和左右可以互换位置</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at center,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at top,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at bottom,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at left,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at right,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at center center,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at top left,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at top right,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at bottom right,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(at bottom left,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@3d1724844031a25e6dd6f197828c2ae4e4290599/2021/02/03/537bb6c5ea524f6d455f03b4b6f45f74.png"></p>
<ul>
<li><strong>如果方向为具体数值确定圆心</strong><ul>
<li>可以是正数也可以是负数，可以超出范围</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">0</span> <span class="number">0</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">50px</span> <span class="number">50px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">100px</span> <span class="number">50px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">50px</span> <span class="number">100px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">100px</span> <span class="number">100px</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@75db9ecf85346255e4e5f0406c282f82c53949ec/2021/02/03/076753e0fe6f2fb8a0a11abedfe235e0.png"></p>
<ul>
<li><strong>如果方向为百分比确定圆心</strong><ul>
<li>可以是整数也可以是负数，可以超出范围，方向和上面的一样</li>
</ul>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">0</span> <span class="number">0</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">25%</span> <span class="number">25%</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at -<span class="number">25%</span> <span class="number">50%</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">50%</span> <span class="number">150%</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">50%</span> <span class="number">50%</span>,hotpink, darkblue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@8f016a66afe83ba4dbe092df6678f6fb933a6477/2021/02/03/d459f994c993c54e52b6f4edc27aa609.png"></p>
<h2 id="颜色参数-1"><a href="#颜色参数-1" class="headerlink" title="颜色参数"></a>颜色参数</h2><ul>
<li>颜色参数和线性渐变类似，只是径向渐变再算百分比的时候，颜色过渡是从内而外进行的</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(<span class="selector-id">#ffaf7b</span>, <span class="selector-id">#d76d77</span>,<span class="selector-id">#3a1c71</span>); </span><br><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(<span class="selector-id">#ffaf7b</span>, <span class="selector-id">#d76d77</span> 20% ,<span class="selector-id">#3a1c71</span> 70%); </span><br><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(<span class="selector-id">#ffaf7b</span>, <span class="selector-id">#d76d77</span> 80% ,<span class="selector-id">#3a1c71</span> 90%); </span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@42aad51011b594ddb79df38dd2eb9581f3c55a8f/2021/02/03/8e50241c8f43a447b25d68295509eb6c.png"></p>
<ul>
<li>径向渐变总写法</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(100<span class="selector-tag">px</span> <span class="selector-tag">circle</span> <span class="selector-tag">at</span> 75% 75%,<span class="selector-id">#ffaf7b</span>, <span class="selector-id">#d76d77</span> 20% ,<span class="selector-id">#3a1c71</span> 60%); </span><br><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(200<span class="selector-tag">px</span> 100<span class="selector-tag">px</span> <span class="selector-tag">ellipse</span> <span class="selector-tag">at</span> 25% 25%,<span class="selector-id">#ffaf7b</span>, <span class="selector-id">#d76d77</span> 60% ,<span class="selector-id">#3a1c71</span> 90%); </span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@179edf923cdc83fcd1175d16fcde0db05987aa0c/2021/02/03/81cb78cafaf5433b20985a70b2dafcce.png"></p>
<h2 id="小球案例"><a href="#小球案例" class="headerlink" title="小球案例"></a>小球案例</h2><p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@34b873e03118a42f0a7cad9be4f411a758e59be4/2021/01/19/f1a1affd5bffeefbb392eb9873bf9c1a.png"></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="css">        <span class="selector-class">.box</span>&#123;</span></span><br><span class="line">            width: 200px;</span><br><span class="line">            height: 200px;</span><br><span class="line">            border-radius: 50%;</span><br><span class="line">            border: 1px solid gray;</span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-tag">radial-gradient</span>(<span class="selector-tag">circle</span> <span class="selector-tag">at</span> 25% 25%,<span class="selector-id">#DFFFDF</span>,<span class="selector-id">#00DB00</span>,<span class="selector-id">#28ff28</span>);</span></span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;box&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h1 id="兼容性问题"><a href="#兼容性问题" class="headerlink" title="兼容性问题"></a>兼容性问题</h1><ul>
<li>只需要添加私有前缀就可以解决<br>  注意标准语法要写在最下面，带有私有前缀的就不加to了，方向就是起始点</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">    <span class="attribute">-webkit-background</span>: <span class="built_in">linear-gradient</span>(to left bottom,blue,red);<span class="comment">/* Safari 5.1 - 6.0 */</span></span><br><span class="line">    <span class="attribute">-moz-background</span>: <span class="built_in">linear-gradient</span>(to left bottom,blue,red);<span class="comment">/* Firefox 3.6 - 15 */</span></span><br><span class="line">    <span class="attribute">-ms-background</span>: <span class="built_in">linear-gradient</span>(to left bottom,blue,red);</span><br><span class="line">    <span class="attribute">-o-background</span>: <span class="built_in">linear-gradient</span>(to left bottom,blue,red);<span class="comment">/* Opera 11.1 - 12.0 */</span></span><br><span class="line">    <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to left bottom,blue,red); <span class="comment">/*标准语法*/</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="重复渐变"><a href="#重复渐变" class="headerlink" title="重复渐变"></a>重复渐变</h1><p><code>repeating-linear-gradient() </code>函数和 <code>repeating-radial-gradient()</code> 函数来实现重复的渐变效果.</p>
<h2 id="重复线性渐变"><a href="#重复线性渐变" class="headerlink" title="重复线性渐变"></a>重复线性渐变</h2><p><code>repeating-linear-gradient(&lt;angle&gt; | &lt;side-or-corner&gt;, &lt;color-stop&gt;, &lt;color-stop&gt; +)</code></p>
<ul>
<li><p>第一个参数用于定义线性渐变的方向，并且定义渐变颜色的终止位置。</p>
<ul>
<li>auangle：通过角度来定义渐变的方向。0 度表示渐变方向从下向上，90 度表示渐变从左向右。其角度按照顺时针方向增加。</li>
<li>side-or-corner：通过关键字定义渐变的方向。具有两个关键字，一个表示水平位置（left 或 right），一个表示垂直位置（top 或 bottom）。关键字的先后顺序无影响，并且都是可选的。</li>
</ul>
</li>
<li><p>第二个参数、第三个参数用于定义渐变颜色的起始点和终止点。</p>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 一个由下至上的重复线性渐变,</span></span><br><span class="line"><span class="comment">   从蓝色开始，40%后变绿，</span></span><br><span class="line"><span class="comment">   最后渐变到红色 */</span></span><br><span class="line"><span class="selector-tag">repeating-linear-gradient</span>(0<span class="selector-tag">deg</span>, <span class="selector-tag">blue</span>, <span class="selector-tag">green</span> 40%, <span class="selector-tag">red</span>);</span><br></pre></td></tr></table></figure>
<p>重复渐变须在颜色后边设置起始位置，否则与线性渐变相同</p>
<h2 id="重复径向渐变"><a href="#重复径向渐变" class="headerlink" title="重复径向渐变"></a>重复径向渐变</h2><p><code>repeating-radial-gradient([ [ &lt;shape&gt; ] || &lt;extent-keyword&gt; ] [ at &lt;position&gt; ]?)</code></p>
<p>上述语法的参数说明：</p>
<ul>
<li><p>shape：用于定义径向渐变的形状，包含 circle（圆形）和 ellipse（椭圆形）。</p>
</li>
<li><p>extent-keyword：用于定义径向渐变的边缘形状的位置。</p>
</li>
<li><p>position：用于定义径向渐变的中心点位置。</p>
</li>
<li><p>color-stop：用于定义径向渐变的颜色终止点。</p>
</li>
</ul>
<p>与重复线性渐变相似，需加上位置。也就是颜色后加上结束位置。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 一个由下至上的重复线性渐变,</span></span><br><span class="line"><span class="comment">   从蓝色开始，40%后变绿，</span></span><br><span class="line"><span class="comment">   最后渐变到红色 */</span></span><br><span class="line"><span class="selector-tag">repeating-linear-gradient</span>(0<span class="selector-tag">deg</span>, <span class="selector-tag">blue</span>, <span class="selector-tag">green</span> 40%, <span class="selector-tag">red</span>);</span><br></pre></td></tr></table></figure>


<h2 id="唱片效果"><a href="#唱片效果" class="headerlink" title="唱片效果"></a>唱片效果</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;X-UA-Compatible&quot;</span> <span class="attr">content</span>=<span class="string">&quot;ie=edge&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>重复径向渐变实现唱片效果<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="css">        <span class="selector-class">.radial-gradient</span> &#123;</span></span><br><span class="line">            position: relative;</span><br><span class="line">            width: 262px; </span><br><span class="line">            height: 262px;</span><br><span class="line">            border-radius: 50%;</span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-tag">linear-gradient</span>(30<span class="selector-tag">deg</span>, <span class="selector-tag">transparent</span> 40%, <span class="selector-tag">rgba</span>(42, 41, 40, <span class="selector-class">.85</span>) 40%) <span class="selector-tag">no-repeat</span> 100% 0, <span class="selector-tag">linear-gradient</span>(60<span class="selector-tag">deg</span>, <span class="selector-tag">rgba</span>(42, 41, 40, <span class="selector-class">.85</span>) 60%, <span class="selector-tag">transparent</span> 60%) <span class="selector-tag">no-repeat</span> 0 100%, <span class="selector-tag">repeating-radial-gradient</span>(<span class="selector-id">#2a2928</span>, <span class="selector-id">#2a2928</span> 4<span class="selector-tag">px</span>, <span class="selector-id">#ada9a0</span> 5<span class="selector-tag">px</span>, <span class="selector-id">#2a2928</span> 6<span class="selector-tag">px</span>);</span></span><br><span class="line">            background-size: 50% 100%, 100% 50%, 100% 100%;</span><br><span class="line">        &#125;</span><br><span class="line"><span class="css">        <span class="selector-class">.radial-gradient</span><span class="selector-pseudo">::after</span> &#123;</span></span><br><span class="line">            position: absolute;</span><br><span class="line">            top: 50%; </span><br><span class="line">            left: 50%;</span><br><span class="line">            margin: -35px;</span><br><span class="line"><span class="css">            <span class="selector-tag">border</span>: <span class="selector-tag">solid</span> 1<span class="selector-tag">px</span> <span class="selector-id">#d9a388</span>;</span></span><br><span class="line">            width: 68px; height: 68px;</span><br><span class="line">            border-radius: 50%;</span><br><span class="line"><span class="css">            <span class="selector-tag">box-shadow</span>: 0 0 0 4<span class="selector-tag">px</span> <span class="selector-id">#da5b33</span>, <span class="selector-tag">inset</span> 0 0 0 27<span class="selector-tag">px</span> <span class="selector-id">#da5b33</span>;</span></span><br><span class="line"><span class="css">            <span class="selector-tag">background</span>: <span class="selector-id">#b5ac9a</span>;</span></span><br><span class="line">            content: &#x27;&#x27;;</span><br><span class="line">        &#125;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;radial-gradient&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@ec39a87c747c8f1b85a21f2164ac2d8287b98d3b/2021/01/19/b18d1f4b6e39132641f3839152c95801.png"></p>
<h1 id="动态渐变"><a href="#动态渐变" class="headerlink" title="动态渐变"></a>动态渐变</h1><p>通过预先设置好渐变，通过<code>animation</code>移动<code>background-position</code>来呈现渐变动态变化的效果。为了使动画首尾看上去无缝衔接，渐变的首尾颜色需相同；</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.dynamics</span> &#123;</span><br><span class="line">    <span class="attribute">width</span>: <span class="number">100%</span>;</span><br><span class="line">    <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">90deg</span>, #<span class="number">496</span>eaa, #<span class="number">944</span>fa8, #a8804f, #<span class="number">944</span>fa8, #<span class="number">496</span>eaa);</span><br><span class="line">    <span class="attribute">background-size</span>: <span class="number">1400%</span> <span class="number">300%</span>;</span><br><span class="line">    <span class="attribute">animation</span>: dynamics <span class="number">20s</span> ease infinite;</span><br><span class="line">    <span class="attribute">-webkit-animation</span>: dynamics <span class="number">20s</span> ease infinite;</span><br><span class="line">    <span class="attribute">-moz-animation</span>: dynamics <span class="number">20s</span> ease infinite;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">@keyframes</span> dynamics &#123;</span><br><span class="line">    0% &#123;</span><br><span class="line">        <span class="attribute">background-position</span>: <span class="number">0%</span> <span class="number">0%</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    50% &#123;</span><br><span class="line">        <span class="attribute">background-position</span>: <span class="number">50%</span> <span class="number">100%</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    100% &#123;</span><br><span class="line">        <span class="attribute">background-position</span>: <span class="number">100%</span> <span class="number">0%</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&lt;div class=&quot;dynamics&quot;&gt;&lt;/div&gt;</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">小李博客</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a target="_blank" rel="noopener" href="https://www.antmoe.com/posts/ac319f8f/index.html">https://www.antmoe.com/posts/ac319f8f/index.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://xiaoliblog.cn" target="_blank">小李博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/HTML-CSS/">HTML+CSS</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="/img/wechat.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.png" target="_blank"><img class="post-qr-code-img" src="/img/alipay.png" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/page/css05.html"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">前端三剑客🎉变形</div></div></a></div><div class="next-post pull-right"><a href="/page/css06.html"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">前端三剑客🎉布局</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/page/css08.html" title="前端三剑客🎉定位"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-19</div><div class="title">前端三剑客🎉定位</div></div></a></div><div><a href="/page/css16.html" title="前端三剑客🎉显示与隐藏"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-19</div><div class="title">前端三剑客🎉显示与隐藏</div></div></a></div><div><a href="/page/css10.html" title="前端三剑客🎉浮动"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-19</div><div class="title">前端三剑客🎉浮动</div></div></a></div><div><a href="/page/css11.html" title="前端三剑客🎉过渡"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-19</div><div class="title">前端三剑客🎉过渡</div></div></a></div><div><a href="/page/css14.html" title="前端三剑客🎉网页背景"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-20</div><div class="title">前端三剑客🎉网页背景</div></div></a></div><div><a href="/page/css17.html" title="前端三剑客🎉颜色与单位"><img class="cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@377a52ddfafa27619c25332afa0116a5d7b300fd/2021/04/29/08b487af4b85ca7689126303e28935fc.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-18</div><div class="title">前端三剑客🎉颜色与单位</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">小李博客</div><div class="author-info__description">越努力，越幸运！</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">210</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">38</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">56</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xiaoliblog"><i class="fab fa-github"></i><span>博主的GitHub首页</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/xiaoliblog" target="_blank" title="Gitee"><i class="iconfont icon-gitee card_icon_gitee"></i></a><a class="social-icon" href="https://space.bilibili.com/390969485" target="_blank" title="BiliBili"><i class="iconfont icon-bilibili card_icon_bilibili"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=2312057536&amp;site=CSDN&amp;menu=yes" target="_blank" title="QQ"><i class="iconfont icon-qq card_icon_qq"></i></a><a class="social-icon" href="https://github.com/xiaoliblog" target="_blank" title="GitHub"><i class="iconfont icon-git card_icon_git"></i></a><a class="social-icon" href="https://blog.csdn.net/qq_43266250?spm=1010.2135.3001.5113" target="_blank" title="CSDN"><i class="iconfont icon-csdn card_icon_csdn"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">正在考研备考中💦</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E6%B8%90%E5%8F%98"><span class="toc-number">1.</span> <span class="toc-text">什么是渐变</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98"><span class="toc-number">2.</span> <span class="toc-text">线性渐变</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%B9%E5%90%91%E5%8F%82%E6%95%B0direction"><span class="toc-number">2.1.</span> <span class="toc-text">方向参数direction</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A2%9C%E8%89%B2%E5%8F%82%E6%95%B0"><span class="toc-number">2.2.</span> <span class="toc-text">颜色参数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%B4%E5%83%8F%E6%BB%A4%E9%95%9C%E6%95%88%E6%9E%9C"><span class="toc-number">2.3.</span> <span class="toc-text">头像滤镜效果</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%8A%A8%E7%94%BB"><span class="toc-number">2.4.</span> <span class="toc-text">进度条动画</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%BE%84%E5%90%91%E6%B8%90%E5%8F%98"><span class="toc-number">3.</span> <span class="toc-text">径向渐变</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0shape"><span class="toc-number">3.1.</span> <span class="toc-text">参数shape</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0size"><span class="toc-number">3.2.</span> <span class="toc-text">参数size</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0position"><span class="toc-number">3.3.</span> <span class="toc-text">参数position</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A2%9C%E8%89%B2%E5%8F%82%E6%95%B0-1"><span class="toc-number">3.4.</span> <span class="toc-text">颜色参数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B0%8F%E7%90%83%E6%A1%88%E4%BE%8B"><span class="toc-number">3.5.</span> <span class="toc-text">小球案例</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%BC%E5%AE%B9%E6%80%A7%E9%97%AE%E9%A2%98"><span class="toc-number">4.</span> <span class="toc-text">兼容性问题</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%87%8D%E5%A4%8D%E6%B8%90%E5%8F%98"><span class="toc-number">5.</span> <span class="toc-text">重复渐变</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%87%8D%E5%A4%8D%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98"><span class="toc-number">5.1.</span> <span class="toc-text">重复线性渐变</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%87%8D%E5%A4%8D%E5%BE%84%E5%90%91%E6%B8%90%E5%8F%98"><span class="toc-number">5.2.</span> <span class="toc-text">重复径向渐变</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%94%B1%E7%89%87%E6%95%88%E6%9E%9C"><span class="toc-number">5.3.</span> <span class="toc-text">唱片效果</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8A%A8%E6%80%81%E6%B8%90%E5%8F%98"><span class="toc-number">6.</span> <span class="toc-text">动态渐变</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/page/project01.html" title="前端实例🥳响应式网站首页"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@c19917500ab083c77c7613263ba7ee74d5a08ae6/2021/04/30/469f30b141d73fa0fc4c962662d5813f.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="前端实例🥳响应式网站首页"/></a><div class="content"><a class="title" href="/page/project01.html" title="前端实例🥳响应式网站首页">前端实例🥳响应式网站首页</a><time datetime="2021-04-30T11:50:53.094Z" title="发表于 2021-04-30 19:50:53">2021-04-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/WeChatpay.html" title="微信支付对接"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@f2f670b92ea149650ffa7834354fc90284f2f44a/2021/04/29/5bdc9b381a06193d27cf2fb7c2fb608a.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="微信支付对接"/></a><div class="content"><a class="title" href="/page/WeChatpay.html" title="微信支付对接">微信支付对接</a><time datetime="2021-04-29T12:20:48.070Z" title="发表于 2021-04-29 20:20:48">2021-04-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Alipay.html" title="支付宝支付对接"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61a9b6a6e09e4bda38bb08e3104b717885beaee5/2021/04/29/c3fa51f9cf14e90d9e5a7aa8814dd041.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="支付宝支付对接"/></a><div class="content"><a class="title" href="/page/Alipay.html" title="支付宝支付对接">支付宝支付对接</a><time datetime="2021-04-27T16:00:00.000Z" title="发表于 2021-04-28 00:00:00">2021-04-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Vuejs11.html" title="Vue.js前端框架🎯Pagination+PageHelper实现分页"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61bf4245f6d84d2d0f66d163b89c916788cc1845/2021/04/13/ec6b232f8fe5a840e4bd8c3eabcf49b2.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="Vue.js前端框架🎯Pagination+PageHelper实现分页"/></a><div class="content"><a class="title" href="/page/Vuejs11.html" title="Vue.js前端框架🎯Pagination+PageHelper实现分页">Vue.js前端框架🎯Pagination+PageHelper实现分页</a><time datetime="2021-04-26T14:48:39.701Z" title="发表于 2021-04-26 22:48:39">2021-04-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Vuejs10.html" title="Vue.js前端框架🎯Vue-Element-admin模版"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61bf4245f6d84d2d0f66d163b89c916788cc1845/2021/04/13/ec6b232f8fe5a840e4bd8c3eabcf49b2.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="Vue.js前端框架🎯Vue-Element-admin模版"/></a><div class="content"><a class="title" href="/page/Vuejs10.html" title="Vue.js前端框架🎯Vue-Element-admin模版">Vue.js前端框架🎯Vue-Element-admin模版</a><time datetime="2021-04-19T16:00:00.000Z" title="发表于 2021-04-20 00:00:00">2021-04-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 小李博客</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">🎯Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">🎉Butterfly</a></div><div class="footer_custom_text"><span><a style="margin-inline:5px" target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a><a style="margin-inline:5px" target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a><a style="margin-inline:5px" target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a><a style="margin-inline:5px" target="_blank" href="https://vercel.com/ "><img src="https://img.shields.io/badge/Hosted-Vercel-brightgreen?style=flat&logo=Vercel" title="本站采用双线部署，默认线路托管于Vercel"></a><a style="margin-inline:5px" target="_blank" href="https://coding.net/ "><img src="https://img.shields.io/badge/Hosted-Coding-0cedbe?style=flat&logo=Codio" title="本站采用双线部署，联通线路托管于Coding"></a><a style="margin-inline:5px" target="_blank" href="https://github.com/"><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&logo=GitHub" title="本站项目由Gtihub托管"></a><a style="margin-inline:5px" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&logo=Claris" title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"></a></span></div><div class="icp"><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/"><img class="icp-icon" src="/img/icp.png" alt="ICP"/><span>湘ICP备2021002541号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><div class="search-dialog__title" id="algolia-search-title">Algolia</div><div id="algolia-input-panel"><div id="algolia-search-input"></div></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-stats"></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script><script src="/js/main.js"></script><script defer src="/js/tw_cn.js"></script><script defer src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script><script defer src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script defer src="/js/search/algolia.js"></script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    loader: {
      source: {
        '[tex]/amsCd': '[tex]/amscd'
      }
    },
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        addClass: [200,() => {
          document.querySelectorAll('mjx-container:not([display=\'true\']').forEach( node => {
            const target = node.parentNode
            if (!target.classList.contains('has-jax')) {
              target.classList.add('mathjax-overflow')
            }
          })
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script><script>(()=>{
  const $countDom = document.getElementById('twikoo-count')
  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: 'xiaoliblog-8gj3j5045d5b0896',
      region: ''
    }, null))
  }

  const getCount = () => {
    twikoo.getCommentsCount({
      envId: 'xiaoliblog-8gj3j5045d5b0896',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      $countDom.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const loadTwikoo = (bool = false) => {
    if (typeof twikoo === 'object') {
      init()
      bool && $countDom && setTimeout(getCount,0)
    } else {
      getScript('https://cdn.jsdelivr.net/npm/twikoo@1.3.0/dist/twikoo.all.min.js').then(()=> {
        init()
        bool && $countDom && setTimeout(getCount,0)
      })
    }
  }

  if ('Twikoo' === 'Twikoo' || !true) {
    if (true) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo(true)
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><script defer src="//lib.baomitu.com/jquery/3.5.1/jquery.min.js"></script><script defer src="https://myhkw.cn/api/player/160561664166" id="myhk" key="160561664166" m="1"></script><div><canvas id="snow" style="position:fixed;top:0;left:0;width:100%;height:100%;z-index:99999;pointer-events:none"></canvas></div><script>const notMobile = (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)));</script><scrip async type="text/javascript" src="https://cdn.jsdelivr.net/gh/Candinya/Kratos-Rebirth@latest/source/js/snow.min.js"></scrip><scrip defer src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@latest/source/js/issues.min.js"></scrip><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><script>var gitcalendar = new Vue({
  el: '#gitcalendar',
  data: {
    simplemode: true, 
    user: 'xiaoliblog',
    fixed: 'fixed',
    px: 'px',
    x: '',
    y: '',
    span1: '',
    span2: '',
    month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
    monthchange: [],
    oneyearbeforeday: '',
    thisday: '',
    amonthago: '',
    aweekago: '',
    weekdatacore: 0,
    datacore: 0,
    total: 0,
    datadate: '',
    data: [],
    positionplusdata: [],
    firstweek: [],
    lastweek: [],
    beforeweek: [],
    thisweekdatacore: 0,
    mounthbeforeday: 0,
    mounthfirstindex: 0,
    crispedges: 'crispedges',
    thisdayindex: 0,
    amonthagoindex: 0,
    amonthagoweek: [],
    firstdate: [],
    first2date: [],
    montharrbefore: [],
    monthindex: 0,
    color: ['#ebedf0', '#f1f8ff', '#dbedff', '#c8e1ff', '#79b8ff', '#2188ff', '#0366d6', '#005cc5', '#044289', '#032f62', '#05264c']
  },
  methods: {
    selectStyle(data, event) {
      document.querySelector('.angle-wrapper').style.display = 'block'
      this.span1 = data.date;
      this.span2 = data.count;
      this.x = event.clientX - 100;
      this.y = event.clientY - 60
    },
    outStyle() {
      document.querySelector('.angle-wrapper').style.display = 'none'
    },
    thiscolor(x) {
      if (x === 0) {
        let i = parseInt(x / 2);
        return this.color[0]
      } else if (x < 2) {
        return this.color[1]
      } else if (x < 20) {
        let i = parseInt(x / 2);
        return this.color[i]
      } else {
        return this.color[9]
      }
    },
  }
});
var apiurl = 'python-github-calendar-api-ruby.vercel.app' ? 'https://python-github-calendar-api-ruby.vercel.app/api?' : 'https://githubapi.ryanchristian.dev/user/'
var githubapiurl = apiurl + gitcalendar.user;
//canvas绘图
function responsiveChart() {
  let c = document.getElementById("gitcanvas");
  if (c) {
    let cmessage = document.getElementById("gitmessage");
    let ctx = c.getContext("2d");
    c.width = document.getElementById("gitcalendarcanvasbox").offsetWidth;
    let linemaxwitdh = 0.96 * c.width / gitcalendar.data.length;
    c.height = 9 * linemaxwitdh;
    let lineminwitdh = 0.8 * linemaxwitdh;
    let setposition = {
      x: 0.02 * c.width,
      y: 0.025 * c.width
    };
    for (let week in gitcalendar.data) {
      weekdata = gitcalendar.data[week];
      for (let day in weekdata) {
        let dataitem = {
          date: "",
          count: "",
          x: 0,
          y: 0
        };
        gitcalendar.positionplusdata.push(dataitem);
        ctx.fillStyle = gitcalendar.thiscolor(weekdata[day].count);
        setposition.y = Math.round(setposition.y * 100) / 100;
        dataitem.date = weekdata[day].date;
        dataitem.count = weekdata[day].count;
        dataitem.x = setposition.x;
        dataitem.y = setposition.y;
        ctx.fillRect(setposition.x, setposition.y, lineminwitdh, lineminwitdh);
        setposition.y = setposition.y + linemaxwitdh
      };
      setposition.y = 0.025 * c.width;
      setposition.x = setposition.x + linemaxwitdh
    };
    ctx.font = "600  Arial";
    ctx.fillStyle = '#aaa';
    ctx.fillText("日", 0, 1.9 * linemaxwitdh);
    ctx.fillText("二", 0, 3.9 * linemaxwitdh);
    ctx.fillText("四", 0, 5.9 * linemaxwitdh);
    ctx.fillText("六", 0, 7.9 * linemaxwitdh);
    let monthindexlist = c.width / 24;
    for (let index in gitcalendar.monthchange) {
      ctx.fillText(gitcalendar.monthchange[index], monthindexlist, 0.7 * linemaxwitdh);
      monthindexlist = monthindexlist + c.width / 12
    };
    cmessage.onmousemove = function(event) {
      document.querySelector('.angle-wrapper').style.display = 'none'
    };
    c.onmousemove = function(event) {
      document.querySelector('.angle-wrapper').style.display = 'none'
      getMousePos(c, event);
    };

    function getMousePos(canvas, event) {
      var rect = canvas.getBoundingClientRect();
      var x = event.clientX - rect.left * (canvas.width / rect.width);
      var y = event.clientY - rect.top * (canvas.height / rect.height);
      //console.log("x:"+x+",y:"+y);
      for (let item of gitcalendar.positionplusdata) {
        let lenthx = x - item.x;
        let lenthy = y - item.y;
        //console.log(lenthx,lenthy);
        if (0 < lenthx && lenthx < lineminwitdh) {
          if (0 < lenthy && lenthy < lineminwitdh) {
            //console.log(item.date,item.count)
            document.querySelector('.angle-wrapper').style.display = 'block'
            gitcalendar.span1 = item.date;
            gitcalendar.span2 = item.count;
            gitcalendar.x = event.clientX - 100;
            gitcalendar.y = event.clientY - 60
          }
        }
        //if(0< x - item.x <lineminwitdh&&0< y - item.y <lineminwitdh){
        //console.log(item.count,item.date);
        //}
      }
    }
  }
}
//数据统计算法
function addlastmonth() {
  if (gitcalendar.thisdayindex === 0) {
    thisweekcore(52);
    thisweekcore(51);
    thisweekcore(50);
    thisweekcore(49);
    thisweekcore(48);
    gitcalendar.thisweekdatacore += gitcalendar.firstdate[6].count;
    gitcalendar.amonthago = gitcalendar.firstdate[6].date
  } else {
    thisweekcore(52);
    thisweekcore(51);
    thisweekcore(50);
    thisweekcore(49);
    thisweek2core();
    gitcalendar.amonthago = gitcalendar.first2date[gitcalendar.thisdayindex - 1].date
  }
};

function thisweek2core() {
  for (let i = gitcalendar.thisdayindex - 1; i < gitcalendar.first2date.length; i++) {
    gitcalendar.thisweekdatacore += gitcalendar.first2date[i].count
  }
};

function thisweekcore(index) {
  for (let item of gitcalendar.data[index]) {
    gitcalendar.thisweekdatacore += item.count
  }
};

function addlastweek() {
  for (let item of gitcalendar.lastweek) {
    gitcalendar.weekdatacore += item.count
  }
};

function addbeforeweek() {
  for (let i = gitcalendar.thisdayindex; i < gitcalendar.beforeweek.length; i++) {
    gitcalendar.weekdatacore += gitcalendar.beforeweek[i].count
  }
};

function addweek(data) {
  if (gitcalendar.thisdayindex === 6) {
    gitcalendar.aweekago = gitcalendar.lastweek[0].date;
    addlastweek()
  } else {
    lastweek = data.contributions[51];
    gitcalendar.aweekago = lastweek[gitcalendar.thisdayindex + 1].date;
    addlastweek();
    addbeforeweek()
  }
}

fetch(githubapiurl)
  .then(data => data.json())
  .then(data => {
    gitcalendar.data = data.contributions;
    gitcalendar.total = data.total;
    gitcalendar.first2date = gitcalendar.data[48];
    gitcalendar.firstdate = gitcalendar.data[47];
    gitcalendar.firstweek = data.contributions[0];
    gitcalendar.lastweek = data.contributions[52];
    gitcalendar.beforeweek = data.contributions[51];
    gitcalendar.thisdayindex = gitcalendar.lastweek.length - 1;
    gitcalendar.thisday = gitcalendar.lastweek[gitcalendar.thisdayindex].date;
    gitcalendar.oneyearbeforeday = gitcalendar.firstweek[0].date;
    gitcalendar.monthindex = gitcalendar.thisday.substring(5, 7) * 1;
    gitcalendar.montharrbefore = gitcalendar.month.splice(gitcalendar.monthindex, 12 - gitcalendar.monthindex);
    gitcalendar.monthchange = gitcalendar.montharrbefore.concat(gitcalendar.month);
    addweek(data);
    addlastmonth();
    responsiveChart();
  })
  .catch(function(error) {
    console.log(error);
  });

//手机版更换为svg绘制
if (document.getElementById("gitcalendarcanvasbox").offsetWidth < 500) {
  gitcalendar.simplemode = false
}

//当改变窗口大小时重新绘制canvas
window.onresize = function() {
  if (gitcalendar.simplemode) responsiveChart()
}

//解决滚动滑轮时出现的标签显示
window.onscroll = function() {
  if (document.querySelector('.angle-wrapper')) {
    document.querySelector('.angle-wrapper').style.display = 'none'
  }
};</script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"react":{"opacity":0.7}});</script></body></html>